<template>
	<view class="container">
		<view class="container-info">
			<view class="container-info-box">
				如厕时间：
				<span>{{form.eventTime}}</span>
			</view>
		</view>
		<view class="container-info">
			<view class="container-info-box">
				类型：
				<span>{{getValue(radioList,form.type)}}</span>
			</view>
		</view>
		<view v-if="form.type === '1' || form.type === 1 " class="container-info">
			<view class="container-info-box">
				颜色：
				<span>{{getValue(colorList,form.color)}}</span>
			</view>
		</view>
		<view v-if="form.type === '0' || form.type === 0 " class="container-info">
			<view class="container-info-box">
				颜色：
				<span>{{getValue(colorsList,form.color)}}</span>
			</view>
		</view>
		<view v-if="form.type === '1' || form.type === 1 " class="container-info">
			<view class="container-info-box">
				形态：
				<span>{{getValue(shapeList,form.pottyState)}}</span>
			</view>
		</view>
		<view class="container-info">
			<view class="container-info-box">
				照片：
				<view style="margin-top: 20rpx;">
					<LmageListView 
							:resourceUrls="form.img | resourceUrlFilter" />
					</view>
				</view>
		</view>
	</view>
</template>

<script>
	import {
		getRecordPottyInfo
	} from './api/index.js'
	import recordMixin from './mixins/info.js'
	import LmageListView from '@/components/image-list-view.vue'
	import {
		formatDateByTimestamp
	} from '@/utils/utils.js'
	export default {
		mixins: [recordMixin],
		components: {
			// MultiMediaView,
			LmageListView
		},
		data() {
			return {
				form: {
					eventTime: formatDateByTimestamp(Date.now(), 'yyyy/mm/dd hh:MM:ss'),
					temperature: 36.5,
					emotion: 3,
					bodyState: 3,
					remark: '',
				},
				radioList: [
					{
						name: '小便',
						value: '0',
					},{
						name: '大便',
						value: '1',
					}
				],
				colorList: [{
						name: '正常',
						value: '0',
					},
					{
						name: '偏黑',
						value: '1',
					},
					{
						name: '偏绿',
						value: '2',
					},
					{
						name: '其他',
						value: '3',
					}
				],
				
				colorsList:[
					{
						name: '正常',
						value: '0',
					},
					{
						name: '偏黄',
						value: '1',
					},
				],
				
				shapeList: [{
						name: '正常',
						value: '0',
					},
					{
						name: '偏稀',
						value: '1',
					},
					{
						name: '偏硬',
						value: '2',
					}
				],
			}
		},
		filters: {
			resourceUrlFilter (value) {
				if (!value) {
					return []
				}
				return value.split('|');
			}
		},
		methods: {
			getValue(list,value) {
				return list.find(item => item.value * 1 === value * 1)?.name
			},
			getRecord() {
				console.log(this.recordId)
				if (this.$u.test.isEmpty(this.recordId)) {
					return;
				}
				uni.showLoading({})
				const params = {
					id: this.recordId,
					childId: this.defaultChildren.id
				}
					getRecordPottyInfo(params).then(res => {
						console.log(res)
						uni.hideLoading()
						const { type, typeStr, color, pottyState, monkeyAss, diaper,img} = res.data; 
						const eventTime = formatDateByTimestamp(res.data.eventTime, 'yyyy/mm/dd hh:MM:ss')
						const form = {
							eventTime,
							type,
							typeStr,
							color,
							pottyState,
							monkeyAss,
							diaper,
							img
						};
						this.form = form
					})	

			},
		}
	}
</script>

<style lang="scss" scoped>


</style>
